package com.example.mediaandroidjava;

import androidx.appcompat.app.AppCompatActivity;
import androidx.media3.ui.PlayerView;

import android.os.Bundle;
import android.view.KeyEvent;

public class UIComponentsActivity extends AppCompatActivity {
    PlayerView playerView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_uicomponents);
        playerView = findViewById(R.id.player_view);
        playerView.requestFocus();
    }

    ///监听按键
    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        return playerView.dispatchKeyEvent(event) || super.dispatchKeyEvent(event);
    }
}